﻿using System.Collections.ObjectModel;
using System.Windows.Media;
using GalaSoft.MvvmLight;
using TfL;

namespace Tfl.Controls.WPF.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class PlatformViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the PlatformViewModel class.
        /// </summary>
        public PlatformViewModel()
        {
            Color = System.Windows.Media.Colors.DarkGray.ToString();
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real": Connect to service, etc...
            ////}
            _arrivals = new ObservableCollection<TrainArrivalViewModel>();
            _arrivals.CollectionChanged += ArrivalsCollectionChanged;
        }

         void ArrivalsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            RaisePropertyChanged("Arrivals");
        }
        public string Platform
        {
            get { return _platform; }
            set 
            { 
                _platform = value; 
                RaisePropertyChanged("Platform");
            }
        }

        public string Line
        {
            get { return _line; }
            set
            {
                _line = value;
                RaisePropertyChanged("Line");
                Color = LineCodes.ToColor(value).ToString();
            }
        }

        public ObservableCollection<TrainArrivalViewModel> Arrivals
        {
            get { return _arrivals; }
            set
            {
                _arrivals = value;
                RaisePropertyChanged("Arrivals");
            }
        }

        public string Color { get; set; }

        private string _platform = string.Empty;
        private string _line = string.Empty;
        private ObservableCollection<TrainArrivalViewModel> _arrivals;
        ////public override void Cleanup()
        ////{
        ////    // Clean own resources if needed

        ////    base.Cleanup();
        ////}

    }
}